package com.cskaoyan.kpi.area;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

/**
 * @ClassName DailyAreaMapper
 * @Description: TODO
 * @Author 远志 zhangsong@cskaoyan.onaliyun.com
 * @Date 2023/2/17 15:09
 * @Version V1.0
 **/
public class DailyAreaMapper extends Mapper<Object, Text, Text, Text> {

    @Override
    protected void map(Object key, Text value, Context context) throws IOException, InterruptedException {
        //106.87.2.229---中国:重庆市:未知---2022-01-14 08:01:53---http://115.29.141.32:8085/#/mall/show/goodsList/190/all---firefox
        String line = value.toString();
        String[] parts = line.split("---");
        String area = parts[1];
        String datetime = parts[2];
        String province = area.split(":")[1];
        String date = datetime.split(" ")[0];
        context.write(new Text(province), new Text(date));
    }
}
